#include "StdAfx.h"
#include "Player.h"

using namespace std;
using namespace cv;

Player::Player(void)
{
}

void Player::setPoints(int frameNum, vector<Point2f> pts) {
	_flow[frameNum] = pts;
}

void Player::addPoints(vector<Point2f> pts) {
	int newFrameIndx = _flow.size();
	setPoints(newFrameIndx, pts);
	_currPoints = pts;
}

bool Player::centroid(Point2f& centroid) {

	float avgX = 0;
	float avgY = 0;
	int size = _currPoints.size();

	if(size == 0) {
		return false;
	}

	for(size_t i = 0; i < _currPoints.size(); i++) {
		Point2f pt = _currPoints[i];

		avgX += pt.x;
		avgY += pt.y;
	}

	centroid = Point2f(avgX / size, avgY / size);

	return true;
}

Player::~Player(void)
{
}
